package com.ztf0337.mycurriculumdesign.Utils;

import com.ztf0337.mycurriculumdesign.entity.Order;
import com.ztf0337.mycurriculumdesign.entity.ParkLot;
import com.ztf0337.mycurriculumdesign.entity.ParkingSpace;
import com.ztf0337.mycurriculumdesign.entity.RentedParkingSpace;
import com.ztf0337.mycurriculumdesign.enums.Type;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class TextDate {
    public static List<ParkLot> getParkLots() {
        List<ParkLot> parkLotList = new ArrayList<>();

        ParkLot lot1 = new ParkLot();
        lot1.setParkLotName("市中心地下停车场");
        lot1.setLocal("人民路100号");
        lot1.setTotalSpaces(200);
        lot1.setAvailableSpaces(45);
        lot1.setType("地下");
        lot1.setStatus(true);  // true = 营业
        lot1.setInformation("配备监控系统，支持支付宝和微信支付");
        lot1.setPhone("021-12345678");
        lot1.setUrl("sss");
        parkLotList.add(lot1);

        ParkLot lot2 = new ParkLot();
        lot2.setParkLotName("阳光购物广场停车场");
        lot2.setLocal("阳光大道88号");
        lot2.setTotalSpaces(120);
        lot2.setAvailableSpaces(12);
        lot2.setType("室外");
        lot2.setStatus(true);
        lot2.setInformation("限高2.5米，靠近商场入口");
        lot2.setPhone("021-87654321");
        lot2.setUrl("sss");
        parkLotList.add(lot2);

        ParkLot lot3 = new ParkLot();
        lot3.setParkLotName("机场3号航站楼停车楼");
        lot3.setLocal("浦东国际机场航站楼C区");
        lot3.setTotalSpaces(500);
        lot3.setAvailableSpaces(300);
        lot3.setType("立体");
        lot3.setStatus(true);
        lot3.setInformation("提供电动汽车充电桩");
        lot3.setPhone("021-23456789");
        lot3.setUrl("sss");
        parkLotList.add(lot3);

        ParkLot lot4 = new ParkLot();
        lot4.setParkLotName("图书馆地下停车场");
        lot4.setLocal("文化路7号");
        lot4.setTotalSpaces(50);
        lot4.setAvailableSpaces(0);
        lot4.setType("地下");
        lot4.setStatus(false);  // false = 暂停营业
        lot4.setInformation("入口狭窄，仅限小型车辆");
        lot4.setPhone("021-34567890");
        lot4.setUrl("sss");
        parkLotList.add(lot4);

        ParkLot lot5 = new ParkLot();
        lot5.setParkLotName("科技园区B区停车场");
        lot5.setLocal("高新路88号");
        lot5.setTotalSpaces(300);
        lot5.setAvailableSpaces(150);
        lot5.setType("室外");
        lot5.setStatus(true);
        lot5.setUrl("sss");
        lot5.setInformation("出入口配备自动识别系统");
        lot5.setPhone("021-45678901");
        parkLotList.add(lot5);

        return parkLotList;
    }

    public static List<ParkingSpace> getParkingSpaces() {
        List<ParkingSpace> parkingSpaces = new ArrayList<>();
        // 停车场 1：市中心地下停车场，id = 1
        ParkingSpace ps1 = new ParkingSpace();
        ps1.setParkLotId(1L);
        ps1.setParkingSpaceNumber("A01");
        ps1.setLocation("入口左侧第一排");
        ps1.setStatus(false);  // 空闲
        ps1.setType("ELECTRIC_SMALL_CAR");
        ps1.setPricePerHours(5.0);
        parkingSpaces.add(ps1);

        ParkingSpace ps2 = new ParkingSpace();
        ps2.setParkLotId(1L);
        ps2.setParkingSpaceNumber("A02");
        ps2.setLocation("入口左侧第二排");
        ps2.setStatus(true);  // 占用
        ps2.setType("GASOLINE_MEDIUM_CAR");
        ps2.setPricePerHours(4.5);
        parkingSpaces.add(ps2);


// 停车场 2：科技园立体车库，id = 2
        ParkingSpace ps3 = new ParkingSpace();
        ps3.setParkLotId(2L);
        ps3.setParkingSpaceNumber("B01");
        ps3.setLocation("三层右侧");
        ps3.setStatus(false);
        ps3.setType("ELECTRIC_MEDIUM_CAR");
        ps3.setPricePerHours(6.0);
        parkingSpaces.add(ps3);

        ParkingSpace ps4 = new ParkingSpace();
        ps4.setParkLotId(2L);
        ps4.setParkingSpaceNumber("B02");
        ps4.setLocation("三层左侧");
        ps4.setStatus(true);
        ps4.setType("GASOLINE_SMALL_CAR");
        ps4.setPricePerHours(4.0);
        parkingSpaces.add(ps4);


// 停车场 3：南门地面停车场，id = 3
        ParkingSpace ps5 = new ParkingSpace();
        ps5.setParkLotId(3L);
        ps5.setParkingSpaceNumber("C01");
        ps5.setLocation("中间区域");
        ps5.setStatus(false);
        ps5.setType("GASOLINE_LARGE_CAR");
        ps5.setPricePerHours(5.5);
        parkingSpaces.add(ps5);

        ParkingSpace ps6 = new ParkingSpace();
        ps6.setParkLotId(3L);
        ps6.setParkingSpaceNumber("C02");
        ps6.setLocation("中间区域靠右");
        ps6.setStatus(true);
        ps6.setType("ELECTRIC_LARGE_CAR");
        ps6.setPricePerHours(6.5);
        parkingSpaces.add(ps6);


// 停车场 4：北站配套停车场，id = 4
        ParkingSpace ps7 = new ParkingSpace();
        ps7.setParkLotId(4L);
        ps7.setParkingSpaceNumber("D01");
        ps7.setLocation("出口右侧");
        ps7.setStatus(false);
        ps7.setType("GASOLINE_MEDIUM_CAR");
        ps7.setPricePerHours(4.0);
        parkingSpaces.add(ps7);

        ParkingSpace ps8 = new ParkingSpace();
        ps8.setParkLotId(4L);
        ps8.setParkingSpaceNumber("D02");
        ps8.setLocation("出口左侧");
        ps8.setStatus(true);
        ps8.setType("ELECTRIC_SMALL_CAR");
        ps8.setPricePerHours(5.0);
        parkingSpaces.add(ps8);


// 停车场 5：东湖景区游客停车场，id = 5
        ParkingSpace ps9 = new ParkingSpace();
        ps9.setParkLotId(5L);
        ps9.setParkingSpaceNumber("E01");
        ps9.setLocation("景区门口左侧");
        ps9.setStatus(false);
        ps9.setType("GASOLINE_SMALL_CAR");
        ps9.setPricePerHours(3.5);
        parkingSpaces.add(ps9);

        ParkingSpace ps10 = new ParkingSpace();
        ps10.setParkLotId(5L);
        ps10.setParkingSpaceNumber("E02");
        ps10.setLocation("景区门口右侧");
        ps10.setStatus(true);
        ps10.setType("GASOLINE_MEDIUM_CAR");
        ps10.setPricePerHours(4.0);
        parkingSpaces.add(ps10);

        return parkingSpaces;
    }

    public static List<RentedParkingSpace> getRentedParkingSpace() {
        List<RentedParkingSpace> rentedList = new ArrayList<>();

        for (int i = 0; i < 5; i++) {
            RentedParkingSpace space = new RentedParkingSpace();
            space.setId((long) i);
            space.setUserId(1000L + i);
            space.setParkLotId(200L + i);
            space.setParkingSpaceId(300L + i);
            space.setStartTime(System.currentTimeMillis() - (i * 3600*1000));  // 开始时间向前推 i 小时
            space.setParkLotName("停车场 " + (char) ('A' + i));
            space.setParkingSpaceNumber("P-" + (i + 1));
            space.setLocation("位置 地下室" + (i + 1) + "区");
            rentedList.add(space);
        }
        return rentedList;
    }

    public static List<Order> getOrders() {
        List<Order> testOrders = List.of(
                new Order(1L, 101L, 201L, 301L, "A-01", "停车场A", "粤A12345", "广州市天河区", 12.0, 1716964800000L, 1716968400000L, "短租", "ORD20250529100000001", true,1.2),
                new Order(2L, 102L, 202L, 302L, "A-02", "停车场B", "粤B23456", "深圳市南山区", 15.0, 1716968400000L, 1716975600000L, "短租", "ORD20250529101000002", true,2.3),
                new Order(3L, 103L, 203L, 303L, "B-01", "停车场C", "粤C34567", "佛山市禅城区", 10.5, 1716972000000L, 1716975600000L, "临时", "ORD20250529102000003", false,4.3),
                new Order(4L, 104L, 204L, 304L, "C-03", "停车场D", "粤D45678", "广州市越秀区", 18.0, 1716961200000L, 1716968400000L, "短租", "ORD20250529103000004", true,12.1),
                new Order(5L, 105L, 205L, 305L, "D-04", "停车场E", "粤E56789", "中山市东区", 22.5, 1716954000000L, 1716961200000L, "长租", "ORD20250529104000005", false,12.1),
                new Order(6L, 106L, 206L, 306L, "E-05", "停车场F", "粤F67890", "珠海市香洲区", 30.0, 1716964800000L, 1716979200000L, "长租", "ORD20250529105000006", true,12.1),
                new Order(7L, 107L, 207L, 307L, "F-06", "停车场G", "粤G78901", "汕头市龙湖区", 9.0, 1716968400000L, 1716972000000L, "临时", "ORD20250529106000007", true,12.1),
                new Order(8L, 108L, 208L, 308L, "G-07", "停车场H", "粤H89012", "江门市蓬江区", 16.0, 1716957600000L, 1716964800000L, "短租", "ORD20250529107000008", true,12.1),
                new Order(9L, 109L, 209L, 309L, "H-08", "停车场I", "粤I90123", "惠州市惠城区", 13.5, 1716961200000L, 1716968400000L, "临时", "ORD20250529108000009", false,12.1),
                new Order(10L, 110L, 210L, 310L, "I-09", "停车场J", "粤J01234", "东莞市南城区", 20.0, 1716954000000L, 1716964800000L, "长租", "ORD20250529109000010", true,12.1)
        );

        return testOrders;
    }


    public static ParkingSpace getParkingSpaceById(Long id) {
        List<ParkingSpace> parkingSpaces = getParkingSpaces();
        for (ParkingSpace p : parkingSpaces) {
            if (p.getId().equals(id)) {
                return p;
            }
        }
        return null;
    }
}
